﻿using System;
using System.Web.Mvc;
using RealtReview.DataAccess.SearchParameters;
using RealtyReview.Business.Interfaces;
using RealtyReview.Business.Models.Review;
using RealtyReview.Models;

namespace RealtyReview.Controllers
{
    public class ManagerController : Controller
    {
        private IReviewsService reviewService;
        private IManagementService managementService;
        public ManagerController(IReviewsService reviewService, IManagementService managementService)
        {
            this.reviewService = reviewService;
            this.managementService = managementService;
        }
        public ActionResult ManagerMenu()
        {
	        var model = reviewService.GetReviews(new ReviewSearchParameters());
            return PartialView("_ManagerMenu", model);
        }

        [HttpPost]
        public JsonResult Approve(Guid reviewId)
        {
            if (managementService.ApproveReview(reviewId))
            {
                return Json("OK. Approved");
            }
            return Json("Failed");
        }

        [HttpPost]
        public JsonResult Reject(Guid reviewId)
        {
            if (managementService.RejectReview(reviewId))
            {
                return Json("OK. Rejected");
            }
            return Json("Failed");
        }
    }
}